// src/stores/models/ToolKit/toolKitStore.ts
import { types } from "mobx-state-tree";
import { ToolKitModel } from "./toolKitModel";

export const ToolKitStore = types.compose(
  ToolKitModel,
  types.model("ToolKitStore")
).actions(self => ({
  // 更新核心数据库配置
  updateCoreDbConfig(config: { 
    host?: string; 
    port?: string; 
    database?: string; 
    username?: string; 
    password?: string 
  }) {
    Object.assign(self.dbConnections.core.config, config);
  },
  
  // 更新重构后数据库配置
  updateRefactoredDbConfig(config: { 
    host?: string; 
    port?: string; 
    database?: string; 
    username?: string; 
    password?: string 
  }) {
    Object.assign(self.dbConnections.refactored.config, config);
  },
  
  // 设置核心数据库连接状态
  setCoreDbConnected(isConnected: boolean) {
    self.dbConnections.core.isConnected = isConnected;
  },
  
  // 设置重构后数据库连接状态
  setRefactoredDbConnected(isConnected: boolean) {
    self.dbConnections.refactored.isConnected = isConnected;
  }
}));

export default ToolKitStore;